package com.web.dao;

import com.web.controller.web.WebWithdrawController;
import com.web.entity.CompanyReport;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * @author FDjavaone
 */
public class CompanyReportSqlProvider {

    public String insertSelective(CompanyReport record) {
        BEGIN();
        INSERT_INTO("t_company_report");
        
        if (record.getAdd() != null) {
            VALUES("`add`", "#{add,jdbcType=VARCHAR}");
        }
        
        if (record.getReduce() != null) {
            VALUES("reduce", "#{reduce,jdbcType=VARCHAR}");
        }
        
        if (record.getMarketFund() != null) {
            VALUES("market_fund", "#{marketFund,jdbcType=VARCHAR}");
        }
        
        if (record.getCompanyFund() != null) {
            VALUES("company_fund", "#{companyFund,jdbcType=VARCHAR}");
        }
        
        if (record.getProfitBal() != null) {
            VALUES("profit_bal", "#{profitBal,jdbcType=VARCHAR}");
        }
        
        if (record.getCoreBal() != null) {
            VALUES("core_bal", "#{coreBal,jdbcType=VARCHAR}");
        }
        
        if (record.getUnWithdraw() != null) {
            VALUES("un_withdraw", "#{unWithdraw,jdbcType=VARCHAR}");
        }
        
        if (record.getPoundage() != null) {
            VALUES("poundage", "#{poundage,jdbcType=VARCHAR}");
        }
        
        if (record.getWithdrawPoundage() != null) {
            VALUES("withdraw_poundage", "#{withdrawPoundage,jdbcType=VARCHAR}");
        }
        
        if (record.getCompanyProfit() != null) {
            VALUES("company_profit", "#{companyProfit,jdbcType=VARCHAR}");
        }
        
        if (record.getConsumeBal() != null) {
            VALUES("consume_bal", "#{consumeBal,jdbcType=VARCHAR}");
        }
        
        if (record.getTotal() != null) {
            VALUES("total", "#{total,jdbcType=VARCHAR}");
        }
        
        if (record.getReserve1() != null) {
            VALUES("reserve1", "#{reserve1,jdbcType=VARCHAR}");
        }
        
        if (record.getReserve2() != null) {
            VALUES("reserve2", "#{reserve2,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getModifyTime() != null) {
            VALUES("modify_time", "#{modifyTime,jdbcType=TIMESTAMP}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(CompanyReport record) {
        BEGIN();
        UPDATE("t_company_report");
        
        if (record.getAdd() != null) {
            SET("`add` = #{add,jdbcType=VARCHAR}");
        }
        
        if (record.getReduce() != null) {
            SET("reduce = #{reduce,jdbcType=VARCHAR}");
        }
        
        if (record.getMarketFund() != null) {
            SET("market_fund = #{marketFund,jdbcType=VARCHAR}");
        }
        
        if (record.getCompanyFund() != null) {
            SET("company_fund = #{companyFund,jdbcType=VARCHAR}");
        }
        
        if (record.getProfitBal() != null) {
            SET("profit_bal = #{profitBal,jdbcType=VARCHAR}");
        }
        
        if (record.getCoreBal() != null) {
            SET("core_bal = #{coreBal,jdbcType=VARCHAR}");
        }
        
        if (record.getUnWithdraw() != null) {
            SET("un_withdraw = #{unWithdraw,jdbcType=VARCHAR}");
        }
        
        if (record.getPoundage() != null) {
            SET("poundage = #{poundage,jdbcType=VARCHAR}");
        }
        
        if (record.getWithdrawPoundage() != null) {
            SET("withdraw_poundage = #{withdrawPoundage,jdbcType=VARCHAR}");
        }
        
        if (record.getCompanyProfit() != null) {
            SET("company_profit = #{companyProfit,jdbcType=VARCHAR}");
        }
        
        if (record.getConsumeBal() != null) {
            SET("consume_bal = #{consumeBal,jdbcType=VARCHAR}");
        }
        
        if (record.getTotal() != null) {
            SET("total = #{total,jdbcType=VARCHAR}");
        }
        
        if (record.getReserve1() != null) {
            SET("reserve1 = #{reserve1,jdbcType=VARCHAR}");
        }
        
        if (record.getReserve2() != null) {
            SET("reserve2 = #{reserve2,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getModifyTime() != null) {
            SET("modify_time = #{modifyTime,jdbcType=TIMESTAMP}");
        }
        
        WHERE("id = #{id,jdbcType=BIGINT}");
        
        return SQL();
    }



    public String selectByPage(WebWithdrawController.WithdrawColumns record) {
        BEGIN();
        SELECT("id");
        SELECT("`add`");
        SELECT("reduce");
        SELECT("market_fund");
        SELECT("company_fund");
        SELECT("profit_bal");
        SELECT("core_bal");
        SELECT("un_withdraw");
        SELECT("poundage");
        SELECT("withdraw_poundage");
        SELECT("company_profit");
        SELECT("consume_bal");
        SELECT("total");
        SELECT("reserve1");
        SELECT("reserve2");
        SELECT("create_time");
        SELECT("modify_time");
        FROM("t_company_report");


        if(record.getBegin_createTime()!=null){
            WHERE("create_time >= #{begin_createTime,jdbcType=TIMESTAMP}");
        }
        if(record.getEnd_createTime()!=null){
            WHERE("create_time <= #{end_createTime,jdbcType=TIMESTAMP}");
        }

        ORDER_BY("create_time desc");

        return SQL();
    }
}